function [y,A] = constructEqu(I,delta)
%UNTITLED2 此处显示有关此函数的摘要
%   此处显示详细说明
[M,N,kI] = size(I);
J = M*N;
% y = reshape(I,J,kI);
% y = reshape(y,J*kI);
I1_0 = I(~isnan(I(:,:,1)));
total_num = (length(I1_0(:))); 
% I_ = zeros(total_num,kI);
% for i=1:kI
%     I_(:,i) = I(~isnan(I(:,:,i)));
% end
y1 = I(~isnan(I));
if numel(y1) < 10
%     disp(numel(y1));
    y=[];
    A=[];
    return;
end

y = zeros(total_num*kI,1);
%矩阵太大，需要用稀疏矩阵
% sparse(i,j,s,m,n) %直接创建稀疏矩阵
% 说明：i、j是非0元素的行、列下标；s是非0元素所形成的向量；m、n是s的行、列维数，可省略；
% i、j、s都是长度相同的向量，生成矩阵的元素s(k)下标分别是i(k)和j(k)
% A = zeros(kI*total_num, 3*total_num);
I = reshape(I,J,kI);
delta = reshape(delta,J,kI);
Sk = sin(delta);
Ck = cos(delta);
r=1;st=1;
si = zeros(total_num*kI*3,1);
sj = zeros(total_num*kI*3,1);
ss = zeros(total_num*kI*3,1);
index=1;r=1;sr=1;c=1;

for j=1:J
    c=(r-1)*3/kI+1;
    for i=1:kI
        if(~isnan(I(j,kI)))
%             r=(j-1)*kI+1; 
            si(sr)=r;
            sj(sr)=c;
            ss(sr)=1;
            sr=sr+1;
            si(sr)=r;
            sj(sr)=c+1;
            ss(sr)=Ck(j,i);
            sr=sr+1;
            si(sr)=r;
            sj(sr)=c+2;
            ss(sr)=-Sk(j,i);
            sr=sr+1;

            y(index)=I(j,i);
            index=index+1;
            r=r+1;
%             c=c+1;
        end
    end
end
% for i=1:kI
%     for j=1:J        
%         if(~isnan(I(j,kI)))             
%             t = mod(r,J);       
%             if t == 0
%                 t=J;
%             end
%             si(st) = r; 
%             sj(st) = t*3-2; 
%             ss(st) = 1;       st=st+1;
%             
%             si(st)=r; 
%             sj(st) = t*3-1; 
%             ss(st) = Ck(i);   st=st+1;
%             
%             si(st)=r;
%             sj(st) = t*3; 
%             ss(st) = Sk(i);   st=st+1;
%             y(r) = I(j,i);
%             r = r+1;
%         end        
%     end
% end
% A = sparse(si,sj,ss,total_num*kI,3*total_num*J);
A = sparse(si,sj,ss);
end

